The goal of this assignment is to first familiarize you with heart rate, and respiration data and their preprocessing. The second part explores how to analyze interpersonal coordination of these signals.
These are the questions you need to be able to answer at the end of the assignment (aka that you need to submit as part of the portfolio)
How do you preprocess heart rate and respiration data? Describe the process. If any data needs to be excluded, list the excluded data and motivate the exclusion.
Do you observe interpersonal coordination in heart rate and respiration? Describe your control baseline, the method used to quantify coordination, and the statistical models used to infer whether coordination was higher than in the baseline. Report the results of the models.
Do you observe differences in coordination between conditions? Report the models and results.
Is respiration coordination a likely driver of heart rate coordination? Describe how you would test for it. Bonus points if you actually run the tests and report methods and results.
N.B. to give you a bit more data I included data from last year (Study1) and from your class (Study2). Note that synchronouns and turn-taking are the same across both studies, but the third condition is different: last year it was self-paced joint reading; this year it was the tv-series conversation. So you might want to exclude the self-paced reading (but, up to you!)
Can you eye-ball which condition if any displays more physiological coordination?
Does this tell you more than just eyeballing the plots?
for (file in files) {
ans_Resp = try(optimizeParam(file$Resp1S, file$Resp2S, par, min.rec = 2, max.rec = 8))
ans_HR = try(optimizeParam(file$HR1S, file$HR2S, par, min.rec = 2, max.rec = 8))
if (length(ans_Resp) > 1) {
Dimension_Resp[n] = ans_Resp$emddim
Radius_Resp[n] = ans_Resp$radius
Delay_Resp[n] = ans_Resp$delay
}
else {
Dimension_Resp[n] = NA
Radius_Resp[n] = NA
Delay_Resp[n] = NA
}
if (length(ans_HR) > 1) {
Dimension_HR[n] = ans_HR$emddim
Radius_HR[n] = ans_HR$radius
Delay_HR[n] = ans_HR$delay
}
else {
Dimension_HR[n] = NA
Radius_HR[n] = NA
Delay_HR[n] = NA
}
n=n+1
}
Optimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample size
for (file in files) {
ans_Resp = try(optimizeParam(file$Resp1S, file$Resp2S, par, min.rec = 2, max.rec = 8))
ans_HR = try(optimizeParam(file$HR1S, file$HR2S, par, min.rec = 2, max.rec = 8))
if (length(ans_Resp) > 1) {
Dimension_Resp[n] = ans_Resp$emddim
Radius_Resp[n] = ans_Resp$radius
Delay_Resp[n] = ans_Resp$delay
}
else {
Dimension_Resp[n] = NA
Radius_Resp[n] = NA
Delay_Resp[n] = NA
}
if (length(ans_HR) > 1) {
Dimension_HR[n] = ans_HR$emddim
Radius_HR[n] = ans_HR$radius
Delay_HR[n] = ans_HR$delay
}
else {
Dimension_HR[n] = NA
Radius_HR[n] = NA
Delay_HR[n] = NA
}
n=n+1
}
Optimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample sizeOptimal Radius Not found: try again choosing a wider radius span and larger sample size
parameters = data.frame(Dimension_Resp, Radius_Resp, Delay_Resp, Dimension_HR, Radius_HR, Delay_HR)
mean(parameters$Dimension_Resp, na.rm = TRUE) # 2
[1] 2
mean(parameters$Delay_Resp, na.rm = TRUE) # 28
[1] 28
mean(parameters$Radius_Resp, na.rm = TRUE) # 0.378
[1] 0.3778026
Results=crqa (Synch_data$Resp1S, Synch_data$Resp2S, delay=28, embed=2, radius= 0.378,normalize=0,rescale=0,mindiagline = 2,minvertline = 2)
# To plot RQA
RP=Results$RP
RP = matrix(as.numeric(RP), nrow = ncol(RP))
cols = c("white","blue4")
image(RP, xlab = "", ylab = "", col = cols)
# To explore lags of coordination
Profile=drpdfromts(Synch_data$Resp1S, Synch_data$Resp2S,datatype = 'continuous',ws=50,radius=0.443)
timecourse = round( seq(-5000,5000,100)/1000, digit = 1)
maxlag = Profile$maxlag/1000
profile = Profile$profile*100
Prof=data.frame(profile)
ggplot(Prof, aes(timecourse,profile))+geom_line()+ geom_vline(xintercept = timecourse[maxlag], colour='red')
Systematically pre-process the data
Loop through all the files (either with a loop or with a function), check which files should be excluded, if any, and save the pre-processed time-series. Tip: plot and visually inspect the data to figure out which should be excluded. Run crqa on all the pre-processed time-series and save the output (don’t forget to add columns with study, group, condition and trial). Tip: remember to first assess optimal parameters (dimensions, delay, radius) across all timeseries. Tip: it will often fail, just take whatever parameters you get, select optimal across timeseries parameters and run crqa on all timeseries with those. Tip: double check the rr. When I ran the loop, I got very low rr, so I adjusted the radius until the average of rr across all pairs was approx. 4%.
# To create a function that can preprocess the data
preprocessing = function(data) {
data = data %>% group(n = 100, method = 'greedy') %>% dplyr::summarise(time = mean(time,na.rm=T), HR1 = mean(HR1,na.rm=T), HR2 = mean(HR2,na.rm=T), Resp1 = mean(Resp1,na.rm=T), Resp2 = mean(Resp2,na.rm=T))
data$HR1=removeOuts(data$HR1,threshold)
data$HR2=removeOuts(data$HR2,threshold)
data$Resp1=removeOuts(data$Resp1,threshold)
data$Resp2=removeOuts(data$Resp2,threshold)
data$Resp1=scale(data$Resp1)
data$Resp2=scale(data$Resp2)
data$HR1=scale(data$HR1)
data$HR2=scale(data$HR2)
return(data)
}
Advarselsbeskeder:
1: Unknown or uninitialised column: 'Study'.
2: Unknown or uninitialised column: 'Study'.
3: Unknown or uninitialised column: 'Study'.
4: Unknown or uninitialised column: 'Study'.
# To create a loop to preproces all the data
Final_data = data.frame()
filelist = list.files(path = "CleanData", pattern = ".csv")
n=1
for (file in filelist) {
data=read_csv(paste0("CleanData/",file))
Datafile=preprocessing(data)
Datafile$filename = filelist[n]
ans_Resp = try(optimizeParam(Datafile$Resp1, Datafile$Resp2, par, min.rec = 2, max.rec = 8))
ans_HR = try(optimizeParam(Datafile$HR1, Datafile$HR2, par, min.rec = 2, max.rec = 8))
if (length(ans_Resp) > 1) {
Datafile$Dimension_Resp = ans_Resp$emddim
Datafile$Radius_Resp = ans_Resp$radius
Datafile$Delay_Resp = ans_Resp$delay
}
else {
Datafile$Dimension_Resp = NA
Datafile$Radius_Resp = NA
Datafile$Delay_Resp = NA
}
if (length(ans_HR) > 1) {
Datafile$Dimension_HR = ans_HR$emddim
Datafile$Radius_HR = ans_HR$radius
Datafile$Delay_HR = ans_HR$delay
}
else {
Datafile$Dimension_HR = NA
Datafile$Radius_HR = NA
Datafile$Delay_HR = NA
}
Final_data = rbind(Final_data, Datafile)
Resp_plot= ggplot(Datafile, aes(x=time, y= Resp1)) + geom_line(color = "red") + geom_line(aes(x=time, y=Resp2), color = "blue")
HR_plot = ggplot(Datafile, aes(x=time, y= HR1)) + geom_line(color = "purple") + geom_line(aes(x=time, y=HR2), color = "chartreuse4")
final_plot=gridExtra::grid.arrange(Resp_plot, HR_plot)
ggsave(paste0(file, ".png"), plot = final_plot, path = "Plot")
n=n+1
}
Parsed with column specification:
cols(
time = col_double(),
Resp1 = col_integer(),
Resp2 = col_double(),
ECG1 = col_double(),
ECG2 = col_double(),
HR1 = col_double(),
HR2 = col_double()
)
number of columns of result is not a multiple of vector length (arg 1)31102 parsing failures.
row # A tibble: 5 x 5 col row col expected actual file expected <int> <chr> <chr> <chr> <chr> actual 1 8110 Resp1 no trailing characters .99939 'CleanData/Study1_G1_T1_Synchronous.csv' file 2 8112 Resp1 no trailing characters .99939 'CleanData/Study1_G1_T1_Synchronous.csv' row 3 8113 Resp1 no trailing characters .99512 'CleanData/Study1_G1_T1_Synchronous.csv' col 4 8114 Resp1 no trailing characters .99207 'CleanData/Study1_G1_T1_Synchronous.csv' expected 5 8115 Resp1 no trailing characters .99237 'CleanData/Study1_G1_T1_Synchronous.csv'
... ................. ... .................................................................................... ........ .................................................................................... ...... .................................................................................... .... .................................................................................... ... .................................................................................... ... .................................................................................... ........ ....................................................................................
See problems(...) for more details.
Error : NA/NaN/Inf in foreign function call (arg 1)
Error : NA/NaN/Inf in foreign function call (arg 1)
Error : NA/NaN/Inf in foreign function call (arg 1)
|============== | 16% 2 MB
|============== | 16% 2 MB
|============== | 17% 2 MB
|=============== | 17% 2 MB
|=============== | 18% 2 MB
|================ | 18% 2 MB
|================ | 19% 2 MB
|================ | 19% 2 MB
|================= | 20% 2 MB
|================= | 20% 3 MB
|================== | 21% 3 MB
|================== | 21% 3 MB
|================== | 21% 3 MB
|=================== | 22% 3 MB
|=================== | 22% 3 MB
|==================== | 23% 3 MB
|==================== | 23% 3 MB
|==================== | 24% 3 MB
|===================== | 24% 3 MB
|===================== | 25% 3 MB
|====================== | 25% 3 MB
|====================== | 26% 3 MB
|====================== | 26% 3 MB
|======================= | 27% 4 MB
|======================= | 27% 4 MB
|======================== | 27% 4 MB
|======================== | 28% 4 MB
|======================== | 28% 4 MB
|========================= | 29% 4 MB
|========================= | 29% 4 MB
|========================== | 30% 4 MB
|========================== | 30% 4 MB
|========================== | 31% 4 MB
|=========================== | 31% 4 MB
|=========================== | 32% 4 MB
|============================ | 32% 4 MB
|============================ | 33% 4 MB
|============================ | 33% 4 MB
|============================= | 33% 5 MB
|============================= | 34% 5 MB
|============================= | 34% 5 MB
|============================== | 35% 5 MB
|============================== | 35% 5 MB
|=============================== | 36% 5 MB
|=============================== | 36% 5 MB
|=============================== | 37% 5 MB
|================================ | 37% 5 MB
|================================ | 38% 5 MB
|================================= | 38% 5 MB
|================================= | 39% 5 MB
|================================= | 39% 5 MB
|================================== | 39% 5 MB
|================================== | 40% 5 MB
|=================================== | 40% 6 MB
|=================================== | 41% 6 MB
|=================================== | 41% 6 MB
|==================================== | 42% 6 MB
|==================================== | 42% 6 MB
|===================================== | 43% 6 MB
|===================================== | 43% 6 MB
|===================================== | 44% 6 MB
|====================================== | 44% 6 MB
|====================================== | 44% 6 MB
|======================================= | 45% 6 MB
|======================================= | 45% 6 MB
|======================================= | 46% 6 MB
|======================================== | 46% 6 MB
|======================================== | 47% 7 MB
|========================================= | 47% 7 MB
|========================================= | 48% 7 MB
|========================================= | 48% 7 MB
|========================================== | 49% 7 MB
|========================================== | 49% 7 MB
|=========================================== | 50% 7 MB
|=========================================== | 50% 7 MB
|=========================================== | 51% 7 MB
|============================================ | 51% 7 MB
|============================================ | 51% 7 MB
|============================================= | 52% 7 MB
|============================================= | 52% 7 MB
|============================================= | 53% 7 MB
|============================================== | 53% 7 MB
|============================================== | 54% 8 MB
|=============================================== | 54% 8 MB
|=============================================== | 55% 8 MB
|=============================================== | 55% 8 MB
|================================================ | 56% 8 MB
|================================================ | 56% 8 MB
|================================================= | 57% 8 MB
|================================================= | 57% 8 MB
|================================================= | 58% 8 MB
|================================================== | 58% 8 MB
|================================================== | 58% 8 MB
|=================================================== | 59% 8 MB
|=================================================== | 59% 8 MB
|=================================================== | 60% 8 MB
|==================================================== | 60% 9 MB
|==================================================== | 61% 9 MB
|===================================================== | 61% 9 MB
|===================================================== | 62% 9 MB
|===================================================== | 62% 9 MB
|====================================================== | 63% 9 MB
|====================================================== | 63% 9 MB
|======================================================= | 64% 9 MB
|======================================================= | 64% 9 MB
|======================================================= | 64% 9 MB
|======================================================== | 65% 9 MB
|======================================================== | 65% 9 MB
|========================================================= | 66% 9 MB
|========================================================= | 66% 9 MB
|========================================================= | 67% 9 MB
|========================================================== | 67% 10 MB
|========================================================== | 68% 10 MB
|=========================================================== | 68% 10 MB
|=========================================================== | 69% 10 MB
|=========================================================== | 69% 10 MB
|============================================================ | 70% 10 MB
|============================================================ | 70% 10 MB
|============================================================= | 71% 10 MB
|============================================================= | 71% 10 MB
|============================================================= | 71% 10 MB
|============================================================== | 72% 10 MB
|============================================================== | 72% 10 MB
|=============================================================== | 73% 10 MB
|=============================================================== | 73% 10 MB
|=============================================================== | 74% 11 MB
|================================================================ | 74% 11 MB
|================================================================ | 75% 11 MB
|================================================================= | 75% 11 MB
|================================================================= | 76% 11 MB
|================================================================= | 76% 11 MB
|================================================================== | 77% 11 MB
|================================================================== | 77% 11 MB
|=================================================================== | 78% 11 MB
|=================================================================== | 78% 11 MB
|=================================================================== | 79% 11 MB
|==================================================================== | 79% 11 MB
|==================================================================== | 79% 11 MB
|===================================================================== | 80% 11 MB
|===================================================================== | 80% 11 MB
|===================================================================== | 81% 12 MB
|====================================================================== | 81% 12 MB
|====================================================================== | 82% 12 MB
|======================================================================= | 82% 12 MB
|======================================================================= | 83% 12 MB
|======================================================================= | 83% 12 MB
|======================================================================== | 84% 12 MB
|======================================================================== | 84% 12 MB
|========================================================================= | 85% 12 MB
|========================================================================= | 85% 12 MB
|========================================================================== | 86% 12 MB
|========================================================================== | 86% 12 MB
|========================================================================== | 87% 12 MB
|=========================================================================== | 87% 12 MB
|=========================================================================== | 87% 13 MB
|============================================================================ | 88% 13 MB
|============================================================================ | 88% 13 MB
|============================================================================ | 89% 13 MB
|============================================================================= | 89% 13 MB
|============================================================================= | 90% 13 MB
|============================================================================== | 90% 13 MB
|============================================================================== | 91% 13 MB
|============================================================================== | 91% 13 MB
|=============================================================================== | 92% 13 MB
|=============================================================================== | 92% 13 MB
|================================================================================ | 93% 13 MB
|================================================================================ | 93% 13 MB
|================================================================================ | 93% 13 MB
|================================================================================= | 94% 14 MB
|================================================================================= | 94% 14 MB
|================================================================================== | 95% 14 MB
|================================================================================== | 95% 14 MB
|================================================================================== | 96% 14 MB
|=================================================================================== | 96% 14 MB
|=================================================================================== | 97% 14 MB
|==================================================================================== | 97% 14 MB
|==================================================================================== | 98% 14 MB
|==================================================================================== | 98% 14 MB
|=====================================================================================| 99% 14 MB
|=====================================================================================| 99% 14 MB
|=====================================================================================| 99% 14 MB
|======================================================================================| 100% 14 MB
|======= | 8% 1 MB
|======= | 8% 1 MB
|======= | 9% 1 MB
|======== | 9% 1 MB
|======== | 10% 1 MB
|========= | 10% 1 MB
|========= | 11% 1 MB
|========= | 11% 1 MB
|========== | 12% 1 MB
|========== | 12% 1 MB
|=========== | 12% 1 MB
|=========== | 13% 1 MB
|=========== | 13% 2 MB
|============ | 14% 2 MB
|============ | 14% 2 MB
|============= | 15% 2 MB
|============= | 15% 2 MB
|============= | 16% 2 MB
|============== | 16% 2 MB
|============== | 17% 2 MB
|=============== | 17% 2 MB
|=============== | 17% 2 MB
|=============== | 18% 2 MB
|================ | 18% 2 MB
|================ | 19% 2 MB
|================= | 19% 2 MB
|================= | 20% 2 MB
|================= | 20% 3 MB
|================== | 21% 3 MB
|================== | 21% 3 MB
|================== | 22% 3 MB
|=================== | 22% 3 MB
|=================== | 22% 3 MB
|==================== | 23% 3 MB
|==================== | 23% 3 MB
|==================== | 24% 3 MB
|===================== | 24% 3 MB
|===================== | 25% 3 MB
|====================== | 25% 3 MB
|====================== | 26% 3 MB
|====================== | 26% 3 MB
|======================= | 27% 3 MB
|======================= | 27% 4 MB
|======================== | 28% 4 MB
|======================== | 28% 4 MB
|======================== | 29% 4 MB
|========================= | 29% 4 MB
|========================= | 29% 4 MB
|========================== | 30% 4 MB
|========================== | 30% 4 MB
|========================== | 31% 4 MB
|=========================== | 31% 4 MB
|=========================== | 32% 4 MB
|============================ | 32% 4 MB
|============================ | 33% 4 MB
|============================ | 33% 4 MB
|============================= | 34% 4 MB
|============================= | 34% 5 MB
|============================== | 35% 5 MB
|============================== | 35% 5 MB
|============================== | 35% 5 MB
|=============================== | 36% 5 MB
|=============================== | 36% 5 MB
|================================ | 37% 5 MB
|================================ | 37% 5 MB
|================================ | 38% 5 MB
|================================= | 38% 5 MB
|================================= | 39% 5 MB
|================================== | 39% 5 MB
|================================== | 40% 5 MB
|================================== | 40% 5 MB
|=================================== | 41% 5 MB
|=================================== | 41% 6 MB
|==================================== | 41% 6 MB
|==================================== | 42% 6 MB
|==================================== | 42% 6 MB
|===================================== | 43% 6 MB
|===================================== | 43% 6 MB
|====================================== | 44% 6 MB
|====================================== | 44% 6 MB
|====================================== | 45% 6 MB
|======================================= | 45% 6 MB
|======================================= | 46% 6 MB
|======================================== | 46% 6 MB
|======================================== | 47% 6 MB
|======================================== | 47% 6 MB
|========================================= | 47% 6 MB
|========================================= | 48% 7 MB
|========================================== | 48% 7 MB
|========================================== | 49% 7 MB
|========================================== | 49% 7 MB
|=========================================== | 50% 7 MB
|=========================================== | 50% 7 MB
|============================================ | 51% 7 MB
|============================================ | 51% 7 MB
|============================================ | 52% 7 MB
|============================================= | 52% 7 MB
|============================================= | 53% 7 MB
|============================================== | 53% 7 MB
|============================================== | 53% 7 MB
|============================================== | 54% 7 MB
|=============================================== | 54% 8 MB
|=============================================== | 55% 8 MB
|================================================ | 55% 8 MB
|================================================ | 56% 8 MB
|================================================ | 56% 8 MB
|================================================= | 57% 8 MB
|================================================= | 57% 8 MB
|================================================== | 58% 8 MB
|================================================== | 58% 8 MB
|================================================== | 59% 8 MB
|=================================================== | 59% 8 MB
|=================================================== | 60% 8 MB
|==================================================== | 60% 8 MB
|==================================================== | 60% 8 MB
|==================================================== | 61% 8 MB
|===================================================== | 61% 9 MB
|===================================================== | 62% 9 MB
|====================================================== | 62% 9 MB
|====================================================== | 63% 9 MB
|====================================================== | 63% 9 MB
|======================================================= | 64% 9 MB
|======================================================= | 64% 9 MB
|======================================================== | 65% 9 MB
|======================================================== | 65% 9 MB
|======================================================== | 66% 9 MB
|========================================================= | 66% 9 MB
|========================================================= | 66% 9 MB
|========================================================== | 67% 9 MB
|========================================================== | 67% 9 MB
|========================================================== | 68% 9 MB
|=========================================================== | 68% 10 MB
|=========================================================== | 69% 10 MB
|============================================================ | 69% 10 MB
|============================================================ | 70% 10 MB
|============================================================ | 70% 10 MB
|============================================================= | 71% 10 MB
|============================================================= | 71% 10 MB
|============================================================== | 72% 10 MB
|============================================================== | 72% 10 MB
|============================================================== | 73% 10 MB
|=============================================================== | 73% 10 MB
|=============================================================== | 73% 10 MB
|================================================================ | 74% 10 MB
|================================================================ | 74% 10 MB
|================================================================ | 75% 10 MB
|================================================================= | 75% 11 MB
|================================================================= | 76% 11 MB
|================================================================== | 76% 11 MB
|================================================================== | 77% 11 MB
|================================================================== | 77% 11 MB
|=================================================================== | 78% 11 MB
|=================================================================== | 78% 11 MB
|==================================================================== | 79% 11 MB
|==================================================================== | 79% 11 MB
|==================================================================== | 80% 11 MB
|===================================================================== | 80% 11 MB
|===================================================================== | 80% 11 MB
|===================================================================== | 81% 11 MB
|====================================================================== | 81% 11 MB
|====================================================================== | 82% 12 MB
|======================================================================= | 82% 12 MB
|======================================================================= | 83% 12 MB
|======================================================================= | 83% 12 MB
|======================================================================== | 84% 12 MB
|======================================================================== | 84% 12 MB
|========================================================================= | 85% 12 MB
|========================================================================= | 85% 12 MB
|========================================================================= | 86% 12 MB
|========================================================================== | 86% 12 MB
|========================================================================== | 86% 12 MB
|=========================================================================== | 87% 12 MB
|=========================================================================== | 87% 12 MB
|=========================================================================== | 88% 12 MB
|============================================================================ | 88% 12 MB
|============================================================================ | 89% 13 MB
|============================================================================= | 89% 13 MB
|============================================================================= | 90% 13 MB
|============================================================================= | 90% 13 MB
|============================================================================== | 91% 13 MB
|============================================================================== | 91% 13 MB
|=============================================================================== | 92% 13 MB
|=============================================================================== | 92% 13 MB
|=============================================================================== | 92% 13 MB
|================================================================================ | 93% 13 MB
|================================================================================ | 93% 13 MB
|================================================================================= | 94% 13 MB
|================================================================================= | 94% 13 MB
|================================================================================= | 95% 13 MB
|================================================================================== | 95% 13 MB
|================================================================================== | 96% 14 MB
|=================================================================================== | 96% 14 MB
|=================================================================================== | 97% 14 MB
|=================================================================================== | 97% 14 MB
|==================================================================================== | 98% 14 MB
|==================================================================================== | 98% 14 MB
|=====================================================================================| 99% 14 MB
|=====================================================================================| 99% 14 MB
|=====================================================================================| 99% 14 MB
|======================================================================================| 100% 14 MB
Error : NA/NaN/Inf in foreign function call (arg 1)
Error : NA/NaN/Inf in foreign function call (arg 1)
# To get column with study number
for (file in 1:nrow(Final_data)){
if (grepl("Study1", Final_data$filename[file])){
Final_data$Study[file] = 1}
if (grepl("Study2", Final_data$filename[file])){
Final_data$Study[file] = 2}
}
Unknown or uninitialised column: 'Study'.
# To get group number
Final_data$Group=regmatches(Final_data$filename, regexpr("[G].*[0-9]", Final_data$filename))
Final_data$Group = gsub("[G, _, T]", "", Final_data$Group)
Final_data$Group=substr(Final_data$Group, 1, nchar(Final_data$Group)-1)
# To get trial number
Final_data$Trial=regmatches(Final_data$filename, regexpr("[T].*[0-9]", Final_data$filename))
Final_data$Trial = gsub("[T]", "", Final_data$Trial)
# To get condition
Final_data = Final_data %>% group_by(filename) %>% mutate(Condition = gsub('.{4}$', '', strsplit(filename, "_")[[1]][4]))
mean(Final_data\(Dimension_Resp, na.rm = TRUE) # 3.12 = 3 mean(Final_data\)Radius_Resp, na.rm = TRUE) # 0.596 mean(Final_data$Delay_Resp, na.rm = TRUE) # 28.81 = 29
mean(Final_data\(Dimension_HR, na.rm = TRUE) # 14.24 = 14 mean(Final_data\)Radius_HR, na.rm = TRUE) # 1.274 mean(Final_data$Delay_HR, na.rm = TRUE) # 21.39 = 21
Creating controls: shuffled controls
loop through all pairs and conditions shuffle the timeseries (take a timeseries and rearrange its values in a random order). Tip check the sample() function run crqa and save the output. NB. which delay, embed, radius parameters should you use? statistically compare the crqa indexes in real and shuffled pairs TRICKY! Creating controls: surrogate pair controls
Per each real pair, identify at least one surrogate pair (matching one of the participants, with somebody doing the same task, but in a different pair). Tip: Celine will share a commented script Run crqa on all the surrogate pairs and save the output. NB. which delay, embed, radius parameters should you use? Test whether crqa shows a difference between real and surrogate pairs Testing effects of conditions
make a (probably underpowered) mixed model testing effects of the different conditions on heart rate and respiration coordination N.B: would it make sense to include surrogate pairs? and if so how? what would that tell you? Effects of respiration coordination on heart rate coordination
describe how you would test those. Optional: run the models and report them